<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>05-Vue的事件</title>
    <script src="../js/vue.js"></script>
    <script src="../js/jquery-3.6.0.js"></script>
    <style>
        #box{
            width: 100px;
            height: 100px;
            background-color: pink;
            border: 1px red solid;
        }
        .div{
            background-color: blue;
        }
    </style>
</head>
<body>
<!--1.准备一个div容器-->
<div id="app">
    <button v-on:click="fun1()">鼠标单击</button>
    <button @dblclick="fun2">鼠标双击</button>
    用户名：<input type="text" name="username" @focus="fun3()" @blur="fun4">
    <hr>
    <div id="box" @mouseenter="fun5" @mousemove="fun6" @mouseleave="fun7" @mousedown="fun8" @mouseup="fun9" @keydown="fun10" @keyup="fun11"></div>

</div>
<script>
    <!--2.准备一个Vue对象和容器绑定-->
    const vm = new Vue({
        el: "#app",
        data: {},
        methods: {
            fun1: function () {
                alert("鼠标单击了");
            },
            fun2: function () {
                alert("鼠标双击了");
            },
            fun3: function () {
                console.log("获取焦点");
            },
            fun4: function () {
                console.log("失去焦点");
            },
            fun5: function () {
                console.log("鼠标移入");
            },
            fun6: function () {
                console.log("鼠标移动");
            },
            fun7: function () {
                console.log("鼠标移出");
            },
            fun8: function () {
                console.log("鼠标按下");
                $("#box").css({
                    backgroundColor:"red"
                });
            },
            fun9: function () {
                console.log("鼠标松开");
                $("#box").css({
                    backgroundColor:"pink"
                });
            },
            fun10:function () {
                $("body").css({
                    backgroundColor:"black"
                });
            },
            fun11:function () {
                $("body").css({
                    backgroundColor:"#fff"
                })
            }
        },
    });
</script>
</body>
</html>